#ifndef __PAGELIB_H__
#define __PAGELIB_H__
#include <dirent.h>
#include <openssl/sha.h>
#include <sys/types.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <unordered_set>
#include "../include/Configuration.h"
#include "../include/DirScanner.h"
#include "../include/RssReader.h"
#include "../log/Logger.hpp"

using namespace std;

class PageLib {
   private:
    DirScanner& _dirScanner;  // 目录扫描类对象的引用
    RssReader& _rssReader;
    // std::vector<std::string> _filesBefore;  // 存放格式化之前的xml文件
    std::vector<std::string> _files;  // 存放格式化之后的xml文件
    std::map<int, std::pair<int, int>>
        _offsetLib;  // 存放每篇文档在网页库的位置信息
    unordered_map<string, vector<pair<int, double>>> _invert;

   public:
    PageLib(DirScanner& dirScanner, RssReader& rss);
    ~PageLib();
    void create();  // 创建网页库
    void storeWebPagesFile();
    void storeOffsetFile();
    void storeInvertIndexFile();
    void store();  // 存储网页库和网页偏移库
    void setINvertIndex();
};

#endif